// 引入mysql的配置文件
const db = require('../../db.config');

// 引入sequelize对象
const Sequelize = db.sequelize;

// 引入数据表模型
const cosmeticsRecommend = Sequelize.import('../../schema/base/cosmeticsRecommend');
cosmeticsRecommend.sync({force: false}); // 自动创建表

class CosmeticsRecommendModule {
  /**
   * 设置推荐
   */
  static async setRecommend(create) {
    cosmeticsRecommend.create(create)
  }

  /**
   * 查询推荐
   */
  static async getRecommend(sql) {
    return await cosmeticsRecommend.findAll(sql)
  }

  /**
   * 更新推荐
   */
  static async updateRecommend(sql, data) {
    let rec = await cosmeticsRecommend.findOne(sql)

    rec = data
    return await rec.save()
  }
}

module.exports = CosmeticsRecommendModule
